package h0802;

import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

/**
  * @description 最大n个数和最小n个数的和
  * @author 不知名帅哥
  * @date 2024/8/2 17:22
  * @version 1.0
*/
public class MaxNumbersAndMinNumbers {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();
        LinkedList<Integer> nums=new LinkedList<>();
        //TODO 先去重，再计算
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            //保证不重复，去重
            if (nums.isEmpty()||!nums.contains(a)){
                nums.add(a);
            }
        }
        int m = sc.nextInt();
        Collections.sort(nums);
        int res=getSum(nums,m);
        System.out.println(res);
    }

    private static int getSum(LinkedList<Integer> nums,int m) {
        if (2*m>nums.size()){
            return -1;
        }
        int ans=0;
        for (int i = 0; i < m; i++) {
            ans+=nums.removeFirst();
        }
        for (int i = 0; i <m; i++) {
            ans+=nums.removeLast();
        }
        return ans;
    }
}
